# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : decorator.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/15 下午4:01
"""
from time import sleep, time

from highLevelPython.July15_class_code.util.login_chick import LoginCheck


def checkUserLogin(func):
    def wrapper(*args, **kwargs):
        print('正在检查是否登录')
        # 检查用户是否登录的逻辑写在这里,返回一个检查结果
        # 检查结果是success说明用户已经登录
        result = LoginCheck().checkUserLogin()
        if result == 'success':
            res = func(*args, **kwargs)
            print(f'res:{res}')
            return res
        else:
            # 抛出异常
            print('异常')
            return '异常'

    return wrapper


def decorator(func):
    def new_func(*args, **kwargs):
        print('>>>>>>>>>>>>>>>')
        beginTime = time()
        result = func(*args, **kwargs)  # 执行外部传入的函数,接收返回值
        endTime = time()
        print(f'{func.__name__},运行时间:{endTime - beginTime}s')
        print(f'result:{result}')
        print('<<<<<<<<<<<<<<<')

    return new_func
